package com.neusoft.common;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//定义为拦截器配置类
//Configuration 告诉spring这个是配置类
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns 拦截的路径是啥
        String[] addPathPatterns = {
                "/user/**"
        };

        //excludePathPatterns排除的路径
        String[] excludePathPatterns = {
                "/user/register","/user/login/**/**"
        };

        //创建用户拦截器对象并指定其拦截的路径和排除的路径
        registry.addInterceptor(new Interceptor()).addPathPatterns(addPathPatterns).excludePathPatterns(excludePathPatterns);

    }
}
